package cn.mugutu.finance.service.system.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import cn.mugutu.finance.domain.system.Resource;
import cn.mugutu.finance.service.system.ResourceService;

@Service
public class ResourceServiceImpl extends BaseServiceImpl<Resource> implements ResourceService {

    @Override
    public Resource findByCode(String uri) {
        List list = findByHql("FROM Resource o where o.code = ? ", uri);
        if (list.size() > 0) {
            return (Resource) list.get(0);
        }
        return null;
    }

    @Override
    public List<String> findAllResourceCode() {
        //使用查询缓存(其实必要不大,在权限拦截中已经缓存到成员变量中了.)
        return getSession().createQuery("SELECT o.code FROM Resource o ").setCacheable(true).list();
    }

}
